package cn.com.headfree.workflow.workflowinfo.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.gta.edu.sdk.base.service.impl.BaseServiceImpl;
import com.gta.edu.sdk.common.dto.Page;
import com.gta.edu.sdk.common.dto.Sort;

import cn.com.headfree.workflow.cache.WorkFlowCache;
import cn.com.headfree.workflow.workflowinfo.dao.IWorkFlowInfoDao;
import cn.com.headfree.workflow.workflowinfo.model.TWorkFlowInfo;
import cn.com.headfree.workflow.workflowinfo.service.IWorkFlowInfoService;
/**
 * @description 工作流业务实现
 * @author fengya
 * @date 2015-8-5 下午05:40:39
 */
@Service("workFlowInfoService")
public class WorkFlowInfoServiceImpl extends BaseServiceImpl<TWorkFlowInfo> implements IWorkFlowInfoService{
	@Autowired
	private IWorkFlowInfoDao workFlowInfoDao;
	
//	public TWorkFlowInfo getWorkFlowInfoByBusinessId(String businessId) {
//		return this.workFlowInfoDao.getWorkFlowInfoByBusinessId(businessId);
//	}

	public List<TWorkFlowInfo> findWorkFlowsBySysCode(String sysCode) {
		return this.workFlowInfoDao.findWorkFlowsBySysCode(sysCode);
	}

	public void find(Page<TWorkFlowInfo> page, Sort sort, TWorkFlowInfo workFlowInfo) {
		this.workFlowInfoDao.find(page, sort, workFlowInfo);
	}

	@Override
	public void removeData(String deleteIds) {
		String[] deleteIdStr = deleteIds.split(",");
		TWorkFlowInfo info = null;
		for(String id : deleteIdStr){
			info = this.get(TWorkFlowInfo.class, id);
			info.setDelSign(1);
			this.update(info);
			// 从缓存中移除该工作流对应的缓存数据
			WorkFlowCache.getInstance().removeWorkFlow(id);
		}
	}

}
